﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UCL.Powersource.Analysis;
using System.Collections.ObjectModel;
using System.Diagnostics;
using PowersourceUIToolkit;

namespace UCL.Powersource
{

    
    //[Export(typeof(IStatisticManager))]
    public class StatisticManager : StatisticManagerBase
    {

        public StatisticManager() { }

        [ImportMany(typeof(IStatistic))]
        private List<IStatistic> _AvailableStatisticsImportedList=null;

        protected override bool OnInitializing()
        {
            if (_AvailableStatisticsImportedList != null)
            {
                AvailableStatisticsList = _AvailableStatisticsImportedList.ToDictionary(a => a.Statistic_Guid);
            }
            else
            {
                var r=IoC.GetAllInstances(typeof(IStatistic));
                if (r!=null)
                {
                    AvailableStatisticsList = r.Cast<IStatistic>().ToList().ToDictionary(a => a.Statistic_Guid);
                }
                
            }
            return base.OnInitializing();
        }
    }
}
